package com.example.tiptravel.view.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.tiptravel.R;
import com.example.tiptravel.commom.utils.ImageLoader;
import com.example.tiptravel.entity.home.Labels;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 45820 on 2016/11/9.
 */

public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LbViewHolder> {

    private List<Labels.DataBean> data;
    private Context context;

    public LabelsAdapter(List<Labels.DataBean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public LbViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new LbViewHolder(LayoutInflater.from(context).inflate(R.layout.item_list_main_labels, parent, false));
    }

    @Override
    public void onBindViewHolder(LbViewHolder holder, int position) {
        ImageLoader.getInstance().displayImage(data.get(position).getPic(),context,holder.ivLabelsImg,R.mipmap.bg_scenic_list_media,R.mipmap.bg_scenic_list_media);
        holder.tvLaberlsTitle.setText(data.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return data != null ? data.size() : 0;
    }

    public class LbViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.iv_labels_img)
        ImageView ivLabelsImg;
        @BindView(R.id.tv_laberls_title)
        TextView tvLaberlsTitle;

        public LbViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
